package org.example.models.abstracts;

import org.example.models.interfaces.observe.Observable;
import org.example.models.interfaces.observe.Observer;

import java.util.ArrayList;
import java.util.List;


//Class that manages and updates observers' states in some way.
public abstract class AbstractEvent implements Observable {
    private final String name;

    private boolean isStarted;

    protected final List<Observer> observers;

    public AbstractEvent(String name) {
        this.name = name;
        observers = new ArrayList<>();
    }

    public String getName() {
        return name;
    }

    @Override
    public void addObserver(Observer observer) {
        observers.add(observer);
    }
    @Override
    public void removeObserver(Observer observer) {
        observers.remove(observer);
    }

    @Override
    public void notifyObserver(Observer observer, Object message) { observer.update(message); }

    public boolean isStarted() {
        return isStarted;
    }

    public void setStarted(boolean started) {
        isStarted = started;
    }


}
